package code.juc.stream;

import java.io.IOException;
import java.io.PipedReader;
import java.io.PipedWriter;
import java.util.concurrent.TimeUnit;

/**
 * 流运行主类
 */
public class StreamMain {

    public static void main(String[] args) throws IOException, InterruptedException {
        ReadData readData = new ReadData();
        WriteData writeData = new WriteData();
        PipedWriter writer = new PipedWriter();
        PipedReader reader = new PipedReader();

        reader.connect(writer);

        new Thread(new ThreadRead(readData, reader)).start();

        TimeUnit.SECONDS.sleep(1);

        new Thread(new ThreadWrite(writeData, writer)).start();
    }
}
